package day03;

import java.util.Scanner;

public class CaiShuZi {
    public static void main(String[] args) {
        //扫描仪
        Scanner scan=new Scanner(System.in);
        //随机数
        int a=(int)(Math.random()*100);
        int min=1;
        int max=100;
        //用户猜数字
        System.out.println("猜数字游戏，"+min+"~"+max+"随机数");
        int b=scan.nextInt();
        //猜错-->循环
        while (b!=a){

            if(b>a){//猜大
                System.out.println("猜大了，"+min+"~"+b);
                max=b;
            }else {//猜小
                System.out.println("猜小了，"+b+"~"+max);
                min=b;
            }
//            if(b>a){//猜大
//                max=b;
//                System.out.println("猜大了，"+min+"~"+max);
//            }else {//猜小
//                min=b;
//                System.out.println("猜小了，"+min+"~"+max);
//            }
            //继续猜
            b=scan.nextInt();
        }
        //猜对-->结束
        System.out.println("猜对了");
    }
}
